package io.zpy.dao;

import io.zpy.entity.PushOrder;
import io.zpy.entity.SendRecord;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *
 *  @author wuyifan
 *  @date 2020/5/19
 */
public interface TrackTopicsDao {

    /**
     * 查询订单
     * @param uid 用户id
     * @param pid 订单id
     * @return
     */
    public List<PushOrder> getOwnPushOrders(@Param("uid") String uid, @Param("pid") String pid);
    /**
     * 新增订单
     * @param pushorder
     * @return
     */
    public int addPushOrder(@Param("po")PushOrder pushorder);
    /**
     * 删除订单
     * @param pid
     * @return
     */
    public int delPushOrder(@Param("pid")int pid);
    /**
     * 更新订单
     * @param pushorder
     * @return
     */
    public int editPushOrder(PushOrder pushorder);

    /**
     * 插入发送记录
     * @param sr
     * @return
     */
    public int insertSendRecord(@Param("sr")SendRecord sr);

    /**
     * 根据pid查询对应定时器信息
     * @param pid
     * @return
     */
    public SendRecord getJobInfo(@Param("pid") Integer pid);

    /**
     * 更新订单记录中的定时器job信息
     * @param jobName
     * @param jobGroup
     * @return
     */
    public int updatePoJobInfo(@Param("name")String name , @Param("jobGroup")String jobGroup ,@Param("cronExpression")String cronExpression, @Param("pid")Integer pid, @Param("jobName")String jobName);

    /**
     * 现在添加订单直接先插入定时器信息以防丢失，该方法就是用来检测某一个定时任务是否成功，如果一个订单的定时任务3次都未成功，则剔除
     * @param jobName
     * @param pid
     * @return
     */
    public List<SendRecord> getCountSucOrders(@Param("jobName")String jobName, @Param("pid")Integer pid);

    /**
     * 获得所有job
     * @return
     */
    public List<PushOrder> getAllJobs();
}
